<?php
namespace Hive\Mission;
/**
 * Mission Document Linker Object.
 *
 * It represant a the link between a Mission and a document.
 *
 * @author Xavier VILAIN
 * @package ressource
 * @property int 		$missionid		Mission Id
 * @property string 	$docid			Linked Document Id
 * @property int 		$cname 			Creator Name
 * @property datetime 	$cdate 			Creation Date
 */
class Document extends \Fox\Object {

	/**
	 * Link to Ressource
	 * @var string
	 */
	const LINK_MISSION = "mission";

	/**
	 * Link to Document
	 * @var string
	 */
	const LINK_DOCUMENT = "document";

	/**
	 * (non-PHPdoc)
	 * @see Fox.Object::beforeCreate()
	 */
	protected function beforeCreate() {
		$this->udate = \Fox\Object::sqlDateTime(time());
		$this->uname = \User::current()->getId();
	}
}
\Fox\Dao::infos(Document::className(),new \Fox\Object\Info('mission_documents', \Fox\Databases::DB_APP));

// Link to Document
\Fox\Object\Links::add(\Fox\Dao::link(Document::className(),Document::LINK_DOCUMENT)
	->to(\Fox\Document::className(), Document::LINK_MISSION)
	->on('docid'));